function lists = getClusterLists( config, probe )

    dataset_n  = length( config.datasets );

    for dataset_i = 1: dataset_n

        lists{ dataset_i }  = ...
            getClusterList( ...
                config.datasets{ dataset_i }  , ...
                probe{ dataset_i } ...
                );     
    end

end

function list = getClusterList( config , probe )
%config : one dataset
%return cluster list

    veb = 1;
    
    id = smrs( probe' , 2);
    
    n_cluster = size(id,2);

    if veb==1
        fprintf('%d clusters generate\n' , n_cluster);
    end
    
    
    
    min_frame = 15;
    
    n = length( config.src_list );
    
    min_frame = max( min_frame, round( n / n_cluster ));
    min_frame = min( min_frame, n-2 );        

    [IDX,C] = kmeans(probe,n_cluster,'start',probe(id,:));
    
    list = cell( 1, n_cluster);
    for i = 1 : n_cluster
        id = find(IDX == i);
        if( length( id ) < min_frame )
            d = abs(probe - repmat( C( i,:) , n , 1 ));
            d = sum( d,2);
            [~,ord ] = sort( d);
            id = ord(1:min_frame);
        end
        if(veb==1), fprintf('%d\t', length(id) ); end
        list{i}.src = cell(1,length( id ) );
        list{i}.gt = cell(1,length( id ) );
        list{i}.name = config.name;
        
        for k = 1:length(id)
            list{i}.src{k} = [config.src_root config.src_list{ id(k) }];
            list{i}.gt{k}  = [config.gt_root  config.gt_list{  id(k) }];
        end
    end
    
    if(veb==1), fprintf('\n', length(id) ); end
    
    
%     n = length( config.src_list );
%     
%     fout_src_name = [list_root config.name '_src.txt'];
%     fout_gt_name = [list_root config.name '_gt.txt'];
%     
%     fout_src = fopen(fout_src_name, 'wt');
%     fout_gt  = fopen(fout_gt_name , 'wt');
%     
%     fprintf( fout_src ,'%d\n', n );
%     fprintf( fout_gt  ,'%d\n', n );
%     
%     for j = 1:n
%         fprintf( fout_src , '%s\n', [config.src_root config.src_list{j}] );
%         fprintf( fout_gt  , '%s\n', [config.gt_root  config.gt_list{j} ] );
%     end
%     
%     fclose( fout_src );
%     fclose( fout_gt );
%        
end